package si.banst.statistika;

import java.util.Date;
import java.util.Calendar;

public class DateUtil {
	public static Date nastaviCasNaPolnoc(Date date) {
		Calendar calendar = Calendar.getInstance();

		calendar.setTime(date);
		calendar.set(Calendar.HOUR_OF_DAY, 0);
		calendar.set(Calendar.MINUTE, 0);
		calendar.set(Calendar.SECOND, 0);
		calendar.set(Calendar.MILLISECOND, 0);

		return calendar.getTime();
	}

	public static int primerjajDatumsko(Date datum1, Date datum2) {
		return nastaviCasNaPolnoc(datum1).compareTo(nastaviCasNaPolnoc(datum2));
	}

	public static Date nastaviDatum(int leto, int mesec, int dan) {
		Calendar calendar = Calendar.getInstance();
		calendar.set(leto, mesec, dan);
		return calendar.getTime();
	}
}
